package com.itheima.a02systemdemo1;

public class SystemDemo1 {
    public static void main(String[] args) {

        //获取现在相对于时间原点的时间（1970.1.1。0.0.0，我国东八区加8小时，单位毫秒
        long startTime = System.currentTimeMillis();
        int count=0;
        for (int i = 0; i < 100000; i++) {
            if(isPrime2(i)){
                System.out.println(i);
                count++;
            }
        }
        System.out.println(count);

        long endTime = System.currentTimeMillis();
        System.out.println("Time taken: " + (endTime - startTime));

    }
    public static boolean isPrime1(int n) {
        for (int i = 2; i < n; i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
    public static boolean isPrime2(int n) {
        for (int i = 2; i < Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}
